#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 1e5+10;
int a[maxn];
int tree[maxn*21][3];
int tot = 0;
void build(int a)
{
	int now = 0;
	for(int i = 29;i>=0;i--)
	{
		int x = (a>>i)&1;
		if(!tree[now][x])
		{
			tree[now][x] = (++tot);
			tree[tot][0] = tree[tot][1] = 0;
		}
		now = tree[now][x];
	}
}
int dfs(int rt,int dep)
{
	int k0 = tree[rt][0];
	int k1 = tree[rt][1];
	int ans = 0;
	if(!k0&&!k1) return 0;
	else if(!k0&&k1) return dfs(tree[rt][1],dep-1);
	else if(k0&&!k1) return dfs(tree[rt][0],dep-1);
	else
	{
		return (1<<dep)+min(dfs(tree[rt][1],dep-1),dfs(tree[rt][0],dep-1));
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 0;i<n;i++)
	{
		scanf("%d",&a[i]);
		build(a[i]);
	}
	int ans = dfs(0,29);
	printf("%d\n",ans);
} 
